package com.example.springboot.controller;

import com.example.springboot.common.Constants;
import com.example.springboot.common.Result;
import com.example.springboot.common.RouteConstants;
import com.example.springboot.entity.User;
import com.example.springboot.entity.UserContext;
import com.example.springboot.entity.dto.req.WarningSignalReqDTO;
import com.example.springboot.entity.dto.resp.DocumentFileReturnRespDTO;
import com.example.springboot.entity.dto.resp.WarningSignalRespDTO;
import com.example.springboot.service.DocumentService;
import com.example.springboot.utils.TokenUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: DocumentController
 * Package: com.example.springboot.controller
 * Description:
 *
 * @Author dhn
 * @Create 2024/4/7 21:03
 * @Version 1.0
 */
@RestController
@RequestMapping("/document")
@RequiredArgsConstructor
public class DocumentController {

    private final DocumentService documentService;

    /**
     * 气象信息中预警信号菜单获取数据
     * */
    @PostMapping("/getWarningSignal")
    public Result getWarningSignal(@RequestBody WarningSignalReqDTO requestParam){
        WarningSignalRespDTO warningSignalRespDTO = documentService.getWarningSignal(requestParam);
        if(warningSignalRespDTO.getFileNameList().size()>0&&warningSignalRespDTO.getFilePathList().size()>0){
            return Result.success(warningSignalRespDTO);
        }
        return Result.error("501","数据为空");
    }

    /**
     * 天气专报
     * */
    @GetMapping("/getWeatherReport")
    public Result getWeatherReport(){
        User user = UserContext.getUser();
//        User user = TokenUtils.getCurrentUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.QXFW_CLASS_NAME,RouteConstants.QXFW_FILE_TXZB);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }
    /**
     * 重要天气报告
     * */
    @GetMapping("/getImportantWeatherReport")
    public Result getImportantWeatherReport(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.QXFW_CLASS_NAME,RouteConstants.QXFW_FILE_ZYTQBG);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }
    /**
     * 服务产品中的半年趋势预测
     * */
    @GetMapping("/getBNQSYC")
    public Result getBNQSYC(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.FWCP_CLASS_NAME,RouteConstants.FWCP_FILE_BNQSYC);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }

    /**
     * 服务产品中的风光资源年景公报
     * */
    @GetMapping("/getFGZYNJGB")
    public Result getFGZYNJGB(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.FWCP_CLASS_NAME,RouteConstants.FWCP_FILE_FGZYNJGB);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }


    /**
     * 服务产品中的风光月度趋势预测
     * */
    @GetMapping("/getFGZYYDQSYC")
    public Result getFGZYYDQSYC(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.FWCP_CLASS_NAME,RouteConstants.FWCP_FILE_FGZYYDQSYC);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }

    /**
     * 服务产品中的季度趋势预测
     * */
    @GetMapping("/getJDQSYC")
    public Result getJDQSYC(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.FWCP_CLASS_NAME,RouteConstants.FWCP_FILE_JDQSYC);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }

    /**
     * 服务产品中的未来三个月趋势预测
     * */
    @GetMapping("/getWL3YQSYC")
    public Result getWL3YQSYC(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.FWCP_CLASS_NAME,RouteConstants.FWCP_FILE_WL3YQSYC);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }


    /**
     * 服务产品中的风光资源半年评估
     * */
    @GetMapping("/getBNPG")
    public Result getBNPG(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.FWCP_CLASS_NAME,RouteConstants.FWCP_FILE_BNPG);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }

    /**
     * 服务产品中的风光资源月度评估
     * */
    @GetMapping("/getYDPG")
    public Result getYDPG(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.FWCP_CLASS_NAME,RouteConstants.FWCP_FILE_YDPG);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }

    /**
     * 服务产品中的风光资源季度评估
     * */
    @GetMapping("/getJDPG")
    public Result getJDPG(){
        User user = UserContext.getUser();
        List<DocumentFileReturnRespDTO> documentFileReturnRespDTOS = documentService.getFileReturnService(user, RouteConstants.FWCP_CLASS_NAME,RouteConstants.FWCP_FILE_JDPG);
        return Result.success(Constants.CODE_200,"SUCCESS",documentFileReturnRespDTOS);
    }
}
